package jy.util;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

import org.junit.Test;

public class DateUtil {
	static String dateString = "2014-11-09";
	
	@Test
	public Date getDate() {
		Date date = null;
		try {
			SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
			date = sdf.parse(dateString);
		} catch (ParseException e) {
			System.out.println(e.getMessage());
		}
		System.out.println(date.getYear()+"--"+date.getMonth()+1+"---"+date.getDate());
		return date;

	}
	
	public static Integer GetDiffDays(Date d1, Date d2){
	    long from = d1.getTime();
	    long to = d2.getTime();
	    return (int) ((to - from) / (1000 * 60 * 60 * 24));
	}
}
